package edu.fdzc.learn.controller;

import edu.fdzc.learn.common.Result;
import edu.fdzc.learn.service.CouStuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/courseStu")
public class CouStuController {

    @Autowired
    private CouStuService couStuService;

    @PostMapping("/{courseId}/add")
    private Result addStu(@PathVariable int courseId, @RequestParam int stuId){
        couStuService.insert(courseId,stuId);
        return Result.success();
    }

    @PostMapping("/{courseId}/adds")
    private Result addStus(@PathVariable int courseId, @RequestParam int[] stuIds){
        couStuService.inserts(courseId,stuIds);
        return Result.success();
    }

    @DeleteMapping("/{courseId}/delete")
    private Result deleteStuById(@PathVariable int courseId, @RequestParam int stuId){
        couStuService.delete(courseId,stuId);
        return Result.success();
    }

    @DeleteMapping("/{courseId}/deletes")
    private Result deleteStuByIds(@PathVariable int courseId, @RequestParam int[] stuIds){
        couStuService.deletes(courseId,stuIds);
        return Result.success();
    }

}
